package org.fordprefect.struts2jscalendarplugin.views;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.views.TagLibrary;
import org.apache.struts2.views.freemarker.tags.TagModel;
import org.fordprefect.struts2jscalendarplugin.views.freemarker.tags.HeadModel;
import org.fordprefect.struts2jscalendarplugin.views.freemarker.tags.JSCalendarModel;
import org.fordprefect.struts2jscalendarplugin.views.velocity.components.HeadDirective;
import org.fordprefect.struts2jscalendarplugin.views.velocity.components.JSCalendarDirective;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * Created by IntelliJ IDEA. User: milmber Date: Aug 7, 2007 Time: 10:23:06 AM
 * To change this template use File | Settings | File Templates.
 */
public class JSCalendarTagLibrary implements TagLibrary {

	public static final String JSCALENDAR_TAG_NAME = "jscalendar";
	public static final String HEAD_TAG_NAME = "head";

	public Object getFreemarkerModels(ValueStack valueStack,
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) {

		Map<String, TagModel> models = new HashMap<String, TagModel>(2);
		models.put(HEAD_TAG_NAME, new HeadModel(valueStack, httpServletRequest,
				httpServletResponse));
		models.put(JSCALENDAR_TAG_NAME, new JSCalendarModel(valueStack,
				httpServletRequest, httpServletResponse));

		return models;
	}

	@SuppressWarnings("unchecked")
	public List<Class> getVelocityDirectiveClasses() {
		Class[] directives = new Class[] { HeadDirective.class,
				JSCalendarDirective.class };
		return Arrays.asList(directives);
	}
}
